using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Serialization;

public class LoadingBall : MonoBehaviour
{
    [FormerlySerializedAs("ProgressTxt")]
    [SerializeField]
    private TMP_Text progressTxt;
    [SerializeField]
    private Material loadingBallMat;

    [SerializeField]
    [Range(0,1)]
    private float progress;
    
    private int shaderProgressId;

    private void Start()
    {
        shaderProgressId = Shader.PropertyToID("_Progress");
    }

    private void Update()
    {
        loadingBallMat.SetFloat(shaderProgressId, progress);
        progressTxt.text = Mathf.Floor(progress * 100) + "%";
    }
}
